<!DOCTYPE HTML>
<html  lang="zh" xmlns:th="http://www.thymeleaf.org">
<meta charset="utf-8">
<head th:include="include :: header"></head>
<style type="text/css">
	.col-sm-8.wd {
		margin-left: 50px;
		margin-top: -30px;
	}
	.form-group.re {
		padding-top: 10px;
	}
</style>
<body class="white-bg">

<input type="hidden" id="newByqId" th:value="*{newByqId}"/>
<input type="hidden" id="newPointId" th:value="*{newPointId}"/>
<input type="hidden" id="newDeviceId" th:value="*{newDeviceId}"/>

    <div class="wrapper wrapper-content animated fadeInRight ibox-content">
        <form class="form-horizontal m" id="form-kPdKg-add">
			<div class="form-group" hidden>
				<label class="col-sm-3 control-label">：</label>
				<div class="col-sm-8">
					<input id="byqId" name="byqId" class="form-control" type="text">
				</div>
			</div>
			<div class="form-group" hidden>
				<label class="col-sm-3 control-label">：</label>
				<div class="col-sm-8">
					<input id="pId" name="pId" class="form-control" type="text">
				</div>
			</div>
			<div class="form-group" hidden>
				<label class="col-sm-3 control-label">设备ID：</label>
				<div class="col-sm-8">
					<input id="deviceId" name="deviceId" class="form-control" type="text">
				</div>
			</div>
			<div class="form-group re">
				<label class="col-sm-3 control-label">型号：</label>
				<div class="col-sm-8 wd">
					<input id="model" name="model" class="form-control" type="text">
				</div>
			</div>
			<div class="form-group re">
				<label class="col-sm-3 control-label">编号：</label>
				<div class="col-sm-8 wd">
					<input id="code" name="code" class="form-control" type="text">
				</div>
			</div>
			<div class="form-group" hidden>
				<label class="col-sm-3 control-label">数据状态：</label>
				<div class="col-sm-8">
					<input id="datastate" name="datastate" class="form-control" type="text">
				</div>
			</div>
		</form>
	</div>
    <div th:include="include::footer"></div>
    <script type="text/javascript">
		var prefix = ctx + "assets/kPdKg"

        var byqId = $("#newByqId").val();
        var pointId = $("#newPointId").val();
        var deviceId = $("#newDeviceId").val();

		$("#form-kPdKg-add").validate({
			rules:{
				xxxx:{
					required:true,
				},
			},
			focusCleanup: true
		});
		
		function submitHandler() {
	        if ($.validate.form()) {
//	            $.operate.save(prefix + "/add", $('#form-kPdKg-add').serialize());
	            add();
	        }
	    }

        function add() {
            var model = $("#model").val();			//	编号
            var code = $("#code").val();			//	编号
            $.ajax({
                cache : true,
                type : "POST",
                url : prefix + "/add",
                data : {
                    "byqId": byqId,
                    "pId": pointId,
                    "deviceId": deviceId,
                    "model": model,
                    "code": code,
                    "datastate":"新增"
                },
                async : false,
                error : function(request) {
                    $.modal.alertError("系统错误");
                },
                success : function(data) {
                    $.operate.successCallback(data);
                }
            });
        }

	</script>
</body>
</html>
